﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Newtonsoft.Json;
using System.Web.Services;
using BLL;

namespace PropertyAppraisal.ProjectAppraisal
{
    public partial class PingGuList : System.Web.UI.Page
    {
        //部门表
        private static DepartmentBll Depbll = new DepartmentBll();
        //项目信息表
        private static Basic_InfoBll Basicbll = new Basic_InfoBll();
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        [WebMethod]
        public static string showPing(string name, int deptID)
        {
            var result = Basicbll.DList();
            if (name != "" && !string.IsNullOrWhiteSpace(name))
            {  
                return JsonConvert.SerializeObject(result.Where(n => n.users_Name.Contains(name)));
            }
            else if (deptID > 0)
            {
                return JsonConvert.SerializeObject(result.Where(n => n.department_Id == deptID));
            }
            else
            {
                return JsonConvert.SerializeObject(result);
            }          
        }


        /// <summary>
        /// 绑定部门下拉框
        /// </summary>
        /// <returns></returns>
        public static string departmentBD()
        {
            List<Model.SysDepartment> dept = Depbll.DepartmentBD();
            var HtmlStr = "";
            for (var i = 0; i < dept.Count; i++)
            {
                HtmlStr += "<option value=\"" + dept[i].department_Id + "\">" + dept[i].department_Name + "</option>";
            }
            return HtmlStr;
        }
    }
}